import React from 'react'
import {newsIndexRequest} from 'utils/ApiRequest'
import {NewsList} from 'components/news-item/Index'
export default class Index extends React.Component {
  constructor() {
    super()
    this.state = {}
  }

  componentDidMount(){
    newsIndexRequest()
      .then(res=>{
        if(res.status === 200 && res.data.code === 200) {
          this.setState({data: res.data.data})
        }
      })
      .catch(err=>console.log(err))
  }

  handlerNewsDetail = (e) => {
    console.log(e);
  }

  render() {
    return (
      <div className="App">
        <button onClick={this.handler}>数据</button>
        <NewsList newsList={this.state.data?this.state.data.newsData: []}
        newsDetailHandler={this.handlerNewsDetail}/>
      </div>
    )
  }
}